package com.xpc.test.base;

import cn.hutool.http.HttpStatus;
import lombok.Data;

/**
 * 功能描述：公用的返回结果
 *
 * @author xpc on 2024/4/2 10:03
 */
@Data
public class ResultDto<R> {
    private int code;
    private String message;
    private R result;

    public static ResultDto ok(String message) {
        ResultDto resultDto = new ResultDto();
        resultDto.setCode(HttpStatus.HTTP_OK);
        resultDto.setMessage(message);
        return resultDto;
    }

    public static ResultDto error(String message) {
        ResultDto resultDto = new ResultDto();
        resultDto.setCode(HttpStatus.HTTP_INTERNAL_ERROR);
        resultDto.setMessage(message);
        return resultDto;
    }

    public ResultDto() {
    }
}
